package jf.jextn.converter;

public class NullSafeConveterFacade<V, O> implements Converter<V, O>, IsNullSafe {

    private Converter<V, O> converter;

    public NullSafeConveterFacade(Converter<V, O> converter) {
        this.converter = converter;
    }

    @Override
    public O from(V value) {
        return value == null ? null : converter.from(value);
    }

    @Override
    public V to(O o) {
        return o == null ? null : converter.to(o);
    }

    @Override
    public String toString() {
        return "NullSafeConverterFacade  (" + converter + ")";
    }
}
